{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport useEvent from \"rc-util/es/hooks/useEvent\";\nimport useLayoutEffect from \"rc-util/es/hooks/useLayoutEffect\";\nimport * as React from 'react';\nimport { unstable_batchedUpdates } from 'react-dom';\nimport shallowEqual from 'shallowequal';\nexport function createContext(defaultContext) {\n  var Context = /*#__PURE__*/React.createContext(defaultContext);\n  var Provider = function Provider(_ref) {\n    var value = _ref.value,\n      children = _ref.children;\n    var valueRef = React.useRef(value);\n    valueRef.current = value;\n    var _React$useState = React.useState(function () {\n        return {\n          getValue: function getValue() {\n            return valueRef.current;\n          },\n          listeners: new Set()\n        };\n      }),\n      _React$useState2 = _slicedToArray(_React$useState, 1),\n      context = _React$useState2[0];\n    useLayoutEffect(function () {\n      unstable_batchedUpdates(function () {\n        context.listeners.forEach(function (listener) {\n          listener(value);\n        });\n      });\n    }, [value]);\n    return /*#__PURE__*/React.createElement(Context.Provider, {\n      value: context\n    }, children);\n  };\n  return {\n    Context: Context,\n    Provider: Provider\n  };\n}\nexport function useContextSelector(holder, selector) {\n  var eventSelector = useEvent(typeof selector === 'function' ? selector : function (ctx) {\n    if (!Array.isArray(selector)) {\n      return ctx[selector];\n    }\n    var obj = {};\n    selector.forEach(function (key) {\n      obj[key] = ctx[key];\n    });\n    return obj;\n  });\n  var context = React.useContext(holder === null || holder === void 0 ? void 0 : holder.Context);\n  var _ref2 = context || {},\n    listeners = _ref2.listeners,\n    getValue = _ref2.getValue;\n  var valueRef = React.useRef();\n  valueRef.current = eventSelector(context ? getValue() : null);\n  var _React$useState3 = React.useState({}),\n    _React$useState4 = _slicedToArray(_React$useState3, 2),\n    forceUpdate = _React$useState4[1];\n  useLayoutEffect(function () {\n    if (!context) {\n      return;\n    }\n    function trigger(nextValue) {\n      var nextSelectorValue = eventSelector(nextValue);\n      if (!shallowEqual(valueRef.current, nextSelectorValue)) {\n        forceUpdate({});\n      }\n    }\n    listeners.add(trigger);\n    return function () {\n      listeners.delete(trigger);\n    };\n  }, [context]);\n  return valueRef.current;\n}","map":{"version":3,"names":["_slicedToArray","useEvent","useLayoutEffect","React","unstable_batchedUpdates","shallowEqual","createContext","defaultContext","Context","Provider","_ref","value","children","valueRef","useRef","current","_React$useState","useState","getValue","listeners","Set","_React$useState2","context","forEach","listener","createElement","useContextSelector","holder","selector","eventSelector","ctx","Array","isArray","obj","key","useContext","_ref2","_React$useState3","_React$useState4","forceUpdate","trigger","nextValue","nextSelectorValue","add","delete"],"sources":["/data/messenger.client/node_modules/rc-table/es/ContextSelector/index.js"],"sourcesContent":["import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport useEvent from \"rc-util/es/hooks/useEvent\";\nimport useLayoutEffect from \"rc-util/es/hooks/useLayoutEffect\";\nimport * as React from 'react';\nimport { unstable_batchedUpdates } from 'react-dom';\nimport shallowEqual from 'shallowequal';\nexport function createContext(defaultContext) {\n  var Context = /*#__PURE__*/React.createContext(defaultContext);\n\n  var Provider = function Provider(_ref) {\n    var value = _ref.value,\n        children = _ref.children;\n    var valueRef = React.useRef(value);\n    valueRef.current = value;\n\n    var _React$useState = React.useState(function () {\n      return {\n        getValue: function getValue() {\n          return valueRef.current;\n        },\n        listeners: new Set()\n      };\n    }),\n        _React$useState2 = _slicedToArray(_React$useState, 1),\n        context = _React$useState2[0];\n\n    useLayoutEffect(function () {\n      unstable_batchedUpdates(function () {\n        context.listeners.forEach(function (listener) {\n          listener(value);\n        });\n      });\n    }, [value]);\n    return /*#__PURE__*/React.createElement(Context.Provider, {\n      value: context\n    }, children);\n  };\n\n  return {\n    Context: Context,\n    Provider: Provider\n  };\n}\nexport function useContextSelector(holder, selector) {\n  var eventSelector = useEvent(typeof selector === 'function' ? selector : function (ctx) {\n    if (!Array.isArray(selector)) {\n      return ctx[selector];\n    }\n\n    var obj = {};\n    selector.forEach(function (key) {\n      obj[key] = ctx[key];\n    });\n    return obj;\n  });\n  var context = React.useContext(holder === null || holder === void 0 ? void 0 : holder.Context);\n\n  var _ref2 = context || {},\n      listeners = _ref2.listeners,\n      getValue = _ref2.getValue;\n\n  var valueRef = React.useRef();\n  valueRef.current = eventSelector(context ? getValue() : null);\n\n  var _React$useState3 = React.useState({}),\n      _React$useState4 = _slicedToArray(_React$useState3, 2),\n      forceUpdate = _React$useState4[1];\n\n  useLayoutEffect(function () {\n    if (!context) {\n      return;\n    }\n\n    function trigger(nextValue) {\n      var nextSelectorValue = eventSelector(nextValue);\n\n      if (!shallowEqual(valueRef.current, nextSelectorValue)) {\n        forceUpdate({});\n      }\n    }\n\n    listeners.add(trigger);\n    return function () {\n      listeners.delete(trigger);\n    };\n  }, [context]);\n  return valueRef.current;\n}"],"mappings":"AAAA,OAAOA,cAAc,MAAM,0CAA0C;AACrE,OAAOC,QAAQ,MAAM,2BAA2B;AAChD,OAAOC,eAAe,MAAM,kCAAkC;AAC9D,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAASC,uBAAuB,QAAQ,WAAW;AACnD,OAAOC,YAAY,MAAM,cAAc;AACvC,OAAO,SAASC,aAAa,CAACC,cAAc,EAAE;EAC5C,IAAIC,OAAO,GAAG,aAAaL,KAAK,CAACG,aAAa,CAACC,cAAc,CAAC;EAE9D,IAAIE,QAAQ,GAAG,SAASA,QAAQ,CAACC,IAAI,EAAE;IACrC,IAAIC,KAAK,GAAGD,IAAI,CAACC,KAAK;MAClBC,QAAQ,GAAGF,IAAI,CAACE,QAAQ;IAC5B,IAAIC,QAAQ,GAAGV,KAAK,CAACW,MAAM,CAACH,KAAK,CAAC;IAClCE,QAAQ,CAACE,OAAO,GAAGJ,KAAK;IAExB,IAAIK,eAAe,GAAGb,KAAK,CAACc,QAAQ,CAAC,YAAY;QAC/C,OAAO;UACLC,QAAQ,EAAE,SAASA,QAAQ,GAAG;YAC5B,OAAOL,QAAQ,CAACE,OAAO;UACzB,CAAC;UACDI,SAAS,EAAE,IAAIC,GAAG;QACpB,CAAC;MACH,CAAC,CAAC;MACEC,gB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